package com.hmall.search.web;

import com.hmall.common.dto.PageDTO;
import com.hmall.search.pojo.FiltersVO;
import com.hmall.search.pojo.ItemDoc;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("search")
public class SearchController {

    @Autowired
    private ISearchService searchService;

    /**
     * 自动补全功能---黑马商城
     * @param key
     * @return
     */
    @GetMapping("suggestion")
    public List<String> suggestion(@RequestParam("key") String key){
        return searchService.suggestion(key);
    }

    @PostMapping("filters")
    public FiltersVO getFilters(@RequestBody RequestParams params){
        return searchService.getFilters(params);
    }
    /**
     * 查询分页---黑马商城
     * @param params
     * @return
     */
    @PostMapping("list")
    public PageDTO<ItemDoc> searchList(@RequestBody RequestParams params){
        return searchService.searchList(params);
    }
}
